home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 4 / Apprentice-Release4.iso / Source Code / C / Applications / Python 1.3 / source code / Nt / Modules / config.nt.c next >
Encoding:
C/C++ Source or Header  |  1995-12-17  |  5.0 KB  |  211 lines  |  [TEXT/R*ch]

  1. /* -*- C -*- ***********************************************
  2. Copyright 1991-1995 by Stichting Mathematisch Centrum, Amsterdam,
  3. The Netherlands.
  4.  
  5.                         All Rights Reserved
  6.  
  7. Permission to use, copy, modify, and distribute this software and its 
  8. documentation for any purpose and without fee is hereby granted, 
  9. provided that the above copyright notice appear in all copies and that
  10. both that copyright notice and this permission notice appear in 
  11. supporting documentation, and that the names of Stichting Mathematisch
  12. Centrum or CWI not be used in advertising or publicity pertaining to
  13. distribution of the software without specific, written prior permission.
  14.  
  15. STICHTING MATHEMATISCH CENTRUM DISCLAIMS ALL WARRANTIES WITH REGARD TO
  16. THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
  17. FITNESS, IN NO EVENT SHALL STICHTING MATHEMATISCH CENTRUM BE LIABLE
  18. FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
  19. WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
  20. ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
  21. OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  22.  
  23. ******************************************************************/
  24.  
  25. /* Universal Python configuration file */
  26.  
  27. #ifdef HAVE_CONFIG_H
  28. #include "config.h"
  29. #endif
  30.  
  31. #include <stdio.h>
  32. #include <string.h>
  33.  
  34. #include "myproto.h"
  35. #include "mymalloc.h"
  36. #include "osdefs.h"
  37. #include "intrcheck.h"
  38.  
  39. #ifndef NO_MAIN
  40.  
  41. /* Normally, the main program is called from here (so everything else
  42.    can be in libPython.a).  We save a pointer to argv[0] because it
  43.    may be needed for dynamic loading of modules in import.c.  If you
  44.    have your own main program and want to use non-SunOS dynamic
  45.    loading, you will have to provide your own version of
  46.    getprogramname(). */
  47.  
  48. static char *argv0;
  49.  
  50. main(argc, argv)
  51.     int argc;
  52.     char **argv;
  53. {
  54. #ifdef macintosh
  55.     wargs(&argc, &argv);
  56. #endif
  57.     argv0 = argv[0];
  58.     realmain(argc, argv);
  59. }
  60.  
  61. char *
  62. getprogramname()
  63. {
  64.     return argv0;
  65. }
  66.  
  67. #endif
  68. #ifndef NO_MODULES
  69.  
  70. /* Python version information */
  71.  
  72. #include "patchlevel.h"
  73.  
  74. /* Return the version string.  This is constructed from the official
  75.    version number (from patchlevel.h), and the current date. */
  76.  
  77. #define VERSION "%s (%s)"
  78. #define DATE __DATE__
  79.  
  80. char *
  81. getversion()
  82. {
  83.     static char version[80];
  84.     sprintf(version, VERSION, PATCHLEVEL, DATE);
  85.     return version;
  86. }
  87.  
  88.  
  89. /* Return the copyright string.  This is updated manually. */
  90.  
  91. char *
  92. getcopyright()
  93. {
  94.     return "Copyright 1991-1994 Stichting Mathematisch Centrum, Amsterdam";
  95. }
  96.  
  97.  
  98. /* Return the initial python search path.  This is called once from
  99.    initsys() to initialize sys.path.
  100.    The environment variable PYTHONPATH is fetched and the default path
  101.    appended.  (The Mac has no environment variables, so there the
  102.    default path is always returned.)  The default path may be passed
  103.    to the preprocessor; if not, a system-dependent default is used. */
  104.  
  105. #ifndef PYTHONPATH
  106. #ifdef macintosh
  107. #define PYTHONPATH ": :Lib :Lib:stdwin :Demo"
  108. #endif /* macintosh */
  109. #endif /* !PYTHONPATH */
  110.  
  111. #ifndef PYTHONPATH
  112. #if defined(MSDOS) || defined(NT)
  113. #define PYTHONPATH ".;..\\lib;\\python\\lib"
  114. #endif /* MSDOS || NT */
  115. #endif /* !PYTHONPATH */
  116.  
  117. #ifndef PYTHONPATH
  118. #define PYTHONPATH ".:/usr/local/lib/python"
  119. #endif /* !PYTHONPATH */
  120.  
  121. char *
  122. getpythonpath()
  123. {
  124. #ifdef macintosh
  125.     return PYTHONPATH;
  126. #else /* !macintosh */
  127.     char *path = getenv("PYTHONPATH");
  128.     char *defpath = PYTHONPATH;
  129.     char *buf;
  130.     char *p;
  131.     int n;
  132.  
  133.     if (path == 0 || *path == '\0')
  134.         return defpath;
  135.     n = strlen(path) + strlen(defpath) + 2;
  136.     buf = malloc(n);
  137.     if (buf == NULL)
  138.         return path; /* XXX too bad -- but not likely */
  139.     strcpy(buf, path);
  140.     p = buf + strlen(buf);
  141.     *p++ = DELIM;
  142.     strcpy(p, defpath);
  143.     return buf;
  144. #endif /* !macintosh */
  145. }
  146.  
  147. /* Table of built-in modules.
  148.    These are initialized when first imported.
  149.    Note: selection of optional extensions is now generally done by the
  150.    makesetup script. */
  151. extern void initarray();
  152. extern void initmath();
  153. extern void initparser();
  154. extern void initnt();
  155. extern void initregex();
  156. /* extern void initsocket(); - sockets are in their own DLL */
  157. extern void initstrop();
  158. extern void initstruct();
  159. extern void inittime();
  160. extern void initfcntl();
  161. extern void initmd5();
  162. extern void initrotor();
  163.  
  164. /* -- ADDMODULE MARKER 1 -- */
  165.  
  166. extern void initmarshal();
  167.  
  168. struct {
  169.     char *name;
  170.     void (*initfunc)();
  171. } inittab[] = {
  172.  
  173.     {"array", initarray},
  174.     {"math", initmath},
  175.     {"parser", initparser}, 
  176.     {"nt", initnt},
  177.     {"regex", initregex},
  178. /*    {"socket", initsocket},    - in its own DLL! */
  179.     {"strop", initstrop},
  180.     {"struct", initstruct},
  181.     {"time", inittime},
  182.     {"md5", initmd5},
  183.     {"rotor", initrotor},
  184.  
  185. /* -- ADDMODULE MARKER 2 -- */
  186.  
  187.     /* This module "lives in" with marshal.c */
  188.     {"marshal", initmarshal},
  189.  
  190.     /* These entries are here for sys.builtin_module_names */
  191.     {"__main__", NULL},
  192.     {"__builtin__", NULL},
  193.     {"sys", NULL},
  194.  
  195.     /* Sentinel */
  196.     {0, 0}
  197. };
  198.  
  199. #ifdef USE_FROZEN
  200. #include "frozen.c"
  201. #else
  202. struct frozen {
  203.     char *name;
  204.     char *code;
  205.     int size;
  206. } frozen_modules[] = {
  207.     {0, 0, 0}
  208. };
  209. #endif
  210. #endif /* NO_MODULES */
  211.